#==============================================================================
# FIND LINE WITH A SPECIFIC KEYWORD (CASE INSENSITIVE)
#==============================================================================
FindLine<-function(fs, keyword) { 
	nl<-length(fs)
	comchar<-"!" #character to indicate comments
	splchar<-"=" #sparate variable name and content
	keyword<-toupper(keyword) #make case insensitive
	found<-FALSE
	
	#loop
	for (l in 1:nl) {
		line<-trim(fs[l]) #assign line, but first remove leading/trailing blanks
		if ((substr(line,1,1) != comchar)*(nchar(line) >= 1)) {
			varname<-unlist(strsplit(line,splchar, fixed = TRUE))[1]
			varname<-trim(varname) #remove blanks
			if ((toupper(varname) == keyword)) found<-TRUE
		}
		if (found == TRUE) break #exit loop if keyword was found
	}	
	
	#return result
	if (found == FALSE) {
		return(NA)
	} else {
		return(l)
	}
}